package com.ygxsk.carhome.ui.adapter;

import android.widget.TextView;

import androidx.annotation.Nullable;

import com.blankj.utilcode.util.ObjectUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.MemberItemBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/**
 * Autuhor:itchen
 * Time:2019/11/14 0014  14:37
 * Description: this is 会员主页列表适配器；
 */
public class MemberListAdapter extends BaseQuickAdapter<MemberItemBean, BaseViewHolder> {


    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param layoutResId The layout resource id of each item.
     * @param data        A new list is created out of this one to avoid mutable list
     */
    public MemberListAdapter(int layoutResId, @Nullable List<MemberItemBean> data) {
        super(layoutResId, data);
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper         A fully initialized helper.
     * @param memberItemBean The item that needs to be displayed.
     */
    @Override
    protected void convert(BaseViewHolder helper, MemberItemBean memberItemBean) {

        if (!ObjectUtils.isEmpty(memberItemBean)) {

            //该会员的名称
            String personName = memberItemBean.getPersonName();

            String personPhone = memberItemBean.getPersonPhone();

            //编号
            int memberLevel = memberItemBean.getMemberLevel();

            //类型
            String memberLevelInfo = memberItemBean.getMemberLevelInfo();


            //人员的姓名
            TextView textViewPersonMemberName = (TextView) helper.getView(R.id.textviewpersonmembername);

            //会员的等级
            TextView textViewMemberLevelInfo = (TextView) helper.getView(R.id.textviewmemberlevelinfo);

            //会员的手机号信息；
            TextView textViewPhoneMember = (TextView) helper.getView(R.id.textviewphonemember);

            //filldatas
            //认证体系
            CommUtils.setText(textViewPersonMemberName, personName);
            CommUtils.setText(textViewPhoneMember, personPhone);
            CommUtils.setText(textViewMemberLevelInfo, memberLevelInfo);


        }

    }
}
